package com.milhouz.bomberrokon.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

import com.milhouz.bomberrokon.MainMenuActivity;
import com.milhouz.bomberrokon.R;
import com.stickycoding.Rokon.Rokon;

public class PauseMenuDialog extends Dialog implements OnClickListener {

	private View resumeButton;
	private View soundButton;
	private View quitButton;

	public PauseMenuDialog(Context context) {
		super(context);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pause_dialog);
		quitButton = findViewById(R.id.quitButton);
		quitButton.setOnClickListener(this);
		resumeButton = findViewById(R.id.resumeButton);
		resumeButton.setOnClickListener(this);
		soundButton = findViewById(R.id.soundButton);
		soundButton.setOnClickListener(this);
	}

	@Override
	public void show() {
		super.show();
		Rokon.getRokon().pause();
	}

	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.resumeButton:
			dismiss();
			Rokon.getRokon().unpause();
			break;

		case R.id.soundButton:
			Toast.makeText(getContext(), "Sound", Toast.LENGTH_LONG).show();
			break;

		case R.id.quitButton:
			dismiss();
			Rokon.getRokon().pause();
			Intent i = new Intent(getContext(), MainMenuActivity.class);
			getContext().startActivity(i);
			break;

		}
	}

	@Override
	public void onBackPressed() {
		Rokon.getRokon().unpause();
		super.onBackPressed();
	}

}
